package com.atguigu.lease.common.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author zhaolingqiao
 * @CreateTime 2024/12/9
 * todo:Mybatis-plus，属性自动填充配置类
 */
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    /**
     * todo:配置自动填充属性,createTime
     * @param metaObject
     */
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("开始插入填充：createTime");
        this.strictInsertFill(metaObject,"createTime",Date.class,new Date());
    }

    /**
     * todo:配置自动填充属性，updateTime
     * @param metaObject
     */
    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("开始更新填充：updateTime");
        this.strictUpdateFill(metaObject,"updateTime",Date.class,new Date());
    }
}
